/*判断document body width*/
var screenW = 0,screenH = 0;
function screenSize(){
	if(window.innerHeight){
		screenH = window.innerHeight;
	}else if((document.body) && (document.body.clientHeight)){
		screenH = document.body.clienHeight;
	}
	if(window.innerWidth){
		screenW = window.innerWidth;
	}else if((document.body) && (document.body.clientWidth)){
		screenW = document.body.clienWidth;
	}
	if(document.documentElement && document.documentElement.clientHeight && document.documentElement.clientWidth){
		screenW = document.documentElement.clientWidth;
		screenH = document.documentElement.clientHeight;
	}
}

/*editblock clear style*/
function editclearstyle(){
	var editbc = $(".edit_txt");
	editbc.find("p").each(function(){
		$(this).removeAttr('style');
	})
	editbc.find("table").each(function(){
		$(this).removeAttr('width');
		$(this).removeAttr('height');
		$(this).removeAttr('style');
		$(this).attr('width','100%');
		$(this).css("font-size",14);
	})
	editbc.find("table td").each(function(){
		$(this).removeAttr('width');
		$(this).removeAttr('height');
		$(this).removeAttr('style');
	})
	editbc.find("table tr").each(function(){
		$(this).removeAttr('width');
		$(this).removeAttr('height');
		$(this).removeAttr('style');
	})
	editbc.find("img").each(function(){
		$(this).removeAttr('width');
		$(this).removeAttr('height');
		$(this).removeAttr('style');
		$(this).wrap("<table width='100%' border='0' cellspacing='0' cellpadding='0'><tr><td align='center'></td></tr></table>");
	})
	editbc.find("iframe").each(function(){
		$(this).removeAttr('width');
		$(this).removeAttr('height');
		$(this).removeAttr('style');
		$(this).wrap("<table width='100%' border='0' cellspacing='0' cellpadding='0'><tr><td align='center'></td></tr></table>");
	})
	editbc.find("embed").each(function(){
		$(this).removeAttr('width');
		$(this).removeAttr('height');
		$(this).removeAttr('style');
		$(this).wrap("<table width='100%' border='0' cellspacing='0' cellpadding='0'><tr><td align='center'></td></tr></table>");
	})
}

/*列均分*/
function thumbnailist(thumbblcok,thumbul){
	var listwidth = $(thumbblcok).width();
	var listliamargin = $(thumbul+" li div").css("marginRight");
	$(thumbul).css("width",listwidth+parseInt(listliamargin));
	$(window).resize(function(){thumbnailist(thumbblcok,thumbul);});
}
function thumbnailist1(thumbblcok,thumbul){
	var listwidth = $(thumbblcok).width();
	var listliamargin = $(thumbul+" div").css("marginRight");
	$(thumbul).css("width",listwidth+parseInt(listliamargin));
	$(window).resize(function(){thumbnailist1(thumbblcok,thumbul);});
}

/*submit data*/
function datasubmit(){
	var uname = $(".initial-show input[name='uname']").val();
		var uphone = $(".initial-show input[name='uphone']").val();
		var uhuxing = $(".form_online-message1 input[name='huxing']").val();
		var umianji = $(".form_online-message1 input[name='mianji']").val();
		var uxiaoqu = $(".form_online-message1 input[name='xiaoqu']").val();
		var ucommend = $(".initial-show input[name='ucommend']").val();
		var ucode = $(".initial-show input[name='ucode']").val();
		$.ajax({
			url:"http://test.winnet.cc/02-10/php/lianxiwomen.php",
			type:"POST",
			data:{name:uname,telephone:uphone,huxing:uhuxing,mianji:umianji,xiaoqu:uxiaoqu,msg_content:ucommend,validate:ucode},
			success:function(data){
				if(data == "pass"){
					$(".online-blockmessage1 .success-show").show();
				}else{
					$(".online-blockmessage1 .wrong-show").show();
				}
			},
			error: function() {
				$(".online-blockmessage1 .wrong-show .txt").html("验证码或者网络错误，预约失败。");
				$(".online-blockmessage1 .wrong-show").show();
			}
		})
}

/*onlinemessage1*/
function onlinemessage1(){
	$(".zoompopwindow").click(function(){
		
		var uname = $(".initial-show input[name='uname']").val();
		var uphone = $(".initial-show input[name='uphone']").val();
		var uhuxing = $(".form_online-message1 input[name='huxing']").val();
		var umianji = $(".form_online-message1 input[name='mianji']").val();
		var uxiaoqu = $(".form_online-message1 input[name='xiaoqu']").val();
		var ucommend = $(".initial-show input[name='ucommend']").val();
		var ucode = $(".initial-show input[name='ucode']").val();
		if(uname ==""){
			$(".initial-show input[name='uname']").addClass("input_textip");
		}else{
			$(".initial-show input[name='uname']").removeClass("input_textip");
		}
		if(uphone == ""){
			$(".initial-show input[name='uphone']").addClass("input_textip");
		}else{
			$(".initial-show input[name='uphone']").removeClass("input_textip");
		}
		if(ucode == ""){
			$(".initial-show input[name='ucode']").addClass("input_textip");
		}else{
			$(".initial-show input[name='ucode']").removeClass("input_textip");
		}
		
		if($(".initial-show input[name='uname']").hasClass("input_textip") || $(".initial-show input[name='uphone']").hasClass("input_textip") || $(".initial-show input[name='ucode']").hasClass("input_textip")){
			return false;
		}else{
			$("#zoomscroll").addClass("loaded").animate({opacity:1},300);;
			$(document.body).addClass("noscroll");
			datasubmit();
		}
	
	})
	
	$(".zoomscrollblockclose").click(function(){
		$("#zoomscroll").animate({opacity:0},100);
		setTimeout(function(){$('#zoomscroll').removeClass('loaded')},200);
		$(document.body).removeClass("noscroll");
		$(".initial-show input[name='uname']").val("");
		$(".initial-show input[name='uphone']").val("");
		$(".initial-show input[name='huxing']").val("");
		$(".initial-show input[name='mianji']").val("");
		$(".initial-show input[name='xiaoqu']").val("");
		$(".initial-show input[name='ucode']").val("");
		$(".initial-show textarea[name='ucommend']").val("");
		$(".online-blockmessage1 .success-show").hide();
		$(".online-blockmessage1 .wrong-show").hide();
	})
}

$(document).ready(function(){
	screenSize();
	
	$(".nav_toggle").click(function(){
			if($(".navblock").height()>60){
				$(".navblock").animate({height:60},300);
			}else{
				$(".navblock").animate({height:432},300);
			}
	})
	
	$(".header1 .wx").click(function(){
		if($(".header1 .wxblock").css("top")=="-150px"){
			$(".header1 .wxblock").animate({opacity:1,top:"40px"},300);
		}else{
			$(".header1 .wxblock").animate({opacity:0,top:"-150px"},300);
		}
	})
	
	var navpopliH = $(".nav .pop li").height()+1;
	$(".nav li").hover(function(){
		if($(this).find("div.pop li").length>0){
			var navpopliN = $(this).find("div.pop li").length;
			var navliH = $(".nav").height()-1;
			$(this).find("div.pop").css({"top":navliH,"height":navpopliN*navpopliH});
		}else{
			return false;
		}
	},function(){
		var navliH = $(".nav").height();
		$(this).find("div.pop").css({"top":navliH-5,"height":0});
	})
	
	var plnow = 0;
	setTimeout(function(){
		$(".nav li a.o").each(function(){
			if($(this).parent().parent().hasClass("on")){
				plnow = $(this).parent().position().left;
			}
		})
		$(".navblock .nowline").css("left",plnow);
	},10)
	$(".nav li a.o").hover(function(){
		var pl = $(this).parent().position().left;
		$(".navblock .nowline").css("left",pl);
	},function(){
		$(".navblock .nowline").css("left",plnow);
	})
	
	/*returntop1*/
	var returntop_btn=$(".returntop");
	returntop_btn.click(function(){
		$("body,html").animate({scrollTop:0},500);
		return false;
	})	
	//$("input").placeholder();
	//$("textarea").placeholder();
		
})
